#include<bits/stdc++.h>
using namespace std;
string s;
string t;
bool c(string s1,string s2){
	
	for(int i=0;i<s1.length();i++){
		char c=s1[0];
		s1.erase(s1.begin());
		s1.push_back(c);
		if(s1.find(s2)!=-1){
			return 1;
		}
	}
	return 0;
}
int  main(){
	cin>>s>>t;
	if(c(s,t)||c(t,s))cout<<"true";
	else cout<<"false";
}
#if 0

// A Better version
// replace c(string,string)

bool c(string s1,string s2){
    s1+=s1;
    return s1.find(s2)!=-1;
}

#endif